package com.qiandw.enterprise.credit

import com.qiandw.enterprise.credit.interceptor.LoginInterceptor
import org.mybatis.spring.annotation.MapperScan
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.context.annotation.{Configuration, EnableAspectJAutoProxy}
import org.springframework.web.servlet.config.annotation.{InterceptorRegistry, WebMvcConfigurerAdapter}

/**
  * Created by Draven on 2018/7/9.
  * Email:hjx@qiandw.com
  */
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
@SpringBootApplication(scanBasePackages = Array("com.qiandw.enterprise.credit"))
@MapperScan(value = Array("com.qiandw.enterprise.credit.mapper"))
class AppConf extends WebMvcConfigurerAdapter {

  override def addInterceptors(registry: InterceptorRegistry): Unit = {
    // addPathPatterns 用于添加拦截规则, 这里假设拦截 /url 后面的全部链接
    // excludePathPatterns 用户排除拦截
    registry.addInterceptor(new LoginInterceptor).addPathPatterns("/management/**")
    super.addInterceptors(registry)
  }
}
